<!DOCTYPE html>  
<html>
<meta charset="utf-8" />  
<title>multiply</title>  
<body>
<h2>multiply</h2> 
</body>
<script language="javascript"type="text/javascript">  
    // sum(1)(2)(3)()//6
    // multiply(1)(2)(3)(..)(n)()//(1)*(2)*(...)*(n)
    
    // 方法一
    const multiply =(function(){

        let list=[];

        const add = function(){
            let args = Array.prototype.slice.call(arguments)
            list = list.concat(args)
            return add;
        }

        add.toString = function(){
            var sum = list.reduce(function(pre,next){
                return pre*next
            })
            return sum
        }
        
        return add;

    })()

    // console.log(multiply(1,2,3))
    // console.log(multiply(1)(2)(3)(4))
    

</script> 
</html>